package com.example.chapter13;


import java.io.File;
import java.nio.file.Path;
import java.nio.file.Paths;

/*
* 13.2.1.文件和目录路径
* */
public class Demo01 {


    public static void main(String[] args) {
        //相对路径
        String relativePath = "data/file.txt";
        File file = new File(relativePath);

        //绝对路径
        String absolutePath = "/home/user/project/data/file.txt";
        File file1 = new File(absolutePath);

        //路径分隔符
        String folder = "data";
        String filename = "file.txt";
        String path = folder + File.separator + filename;
        File file2 = new File(path);


        //使用Paths和Path类（Java 7及以上）
        Path path1 = Paths.get("/home/user/project/data/file.txt");
    }

}
